home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DS-CD ROM 2 1993 August
/
DS CD-ROM 2.Ausgabe (August 1993).iso
/
programm
/
ds0045
/
mbm_src.exe
/
MB_DEMO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-03-22
|
9KB
|
236 lines
program maus_button_demo;
{$S-} {Vollversion 4.1 vom 09.07.1991}
{(C) 1990-92 Software-Entwicklung Uwe Kuhring}
uses drv_link,crt,graph,butlib,mouselib,winlib;
const pieces = 25; {Anzahl der Kreisbuttons}
{auf Ebene 2}
var plane : integer; {Enthält aktuelle Ebene}
{Es folgen die Prozeduren}
procedure mousetest;
var buttons : integer;
begin
mousecheck(buttons); {Anzahl der Mausknöpfe holen}
if mouseerror<0 then begin {Keine Maus oder k. Grafik}
case mouseerror of
-1 : begin
writeln ('Kein Grafikmodus aktiviert!'); {ohne gehts nun}
exit; {wirklich nicht}
end;
-2 : begin {Keine Maus festgestellt}
end; {Reaktion freigestellt ...}
end;
end;
end;
procedure install_buttonplane_1;
begin
{ ┌--Button-Ebene}
{ │ ┌--Button-Nummer}
{ │ │ ┌--X Textspalte}
{ │ │ │ ┌--Y Textzeile}
{ │ │ │ │ ┌---Text im Button}
{ │ │ │ │ │ ┌---Shadowing an/aus ^ true/false}
{ │ │ │ │ │ │ ┌-----ALT ? Button Aktivator}
{ │ │ │ │ │ │ │ ┌------Underline Position}
deftextbutton (1,1,3,3,' Soundschalter ',true,'S',2);
deftextbutton (1,2,3,5,' Frequenz + ',true,'Q',6);
deftextbutton (1,3,3,7,' Frequenz - ',true,'U',7);
deftextbutton (1,4,62,3,' Maus einsperren ',true,'E',7);
deftextbutton (1,5,62,5,' Maus freilassen ',true,'F',7);
deftextbutton (1,6,34,12,' Zur Ebene 2 ',true,'2',12);
deftextbutton (1,7,3,21,' Maus 3 Sekunden ausschalten ',true,'3',7);
deftextbutton (1,8,56,21,' Maus-Button Demo Ende ',true,'M',2);
deftextbutton (1,9,3,12,' Teleport A ',true,'A',11);
deftextbutton (1,10,67,12,' Teleport B ',true,'B',11);
deftextbutton (1,11,38,21,' Kurzinfo ',true,'K',2);
end;
procedure install_buttonplane_2;
var n,x,y : integer;
t : string;
begin
for n:=1 to pieces do begin
x:=39+round(sin(n*2*pi/pieces)*35);
y:=12+round(cos(n*2*pi/pieces)*10);
str (n:2,t);
deftextbutton (2,n,x,y,t,false,' ',0); { <- so gehts auch}
end;
deftextbutton (2,pieces+1,34,12,' Zur Ebene 1 ',true,'1',12);
end;
procedure install_colors;
var t : integer;
begin
button_colors[1,8,0]:=4; {Hintergrundfarbe des Ende-Buttons ist Rot}
button_colors[1,6,0]:=5; { " des Buttons zum Ebene-Wechseln ist Vio}
button_colors[1,11,0]:=3; { " des Kurzinfo-Buttons ist Cyan}
button_colors[1,11,2]:=11; {Zeichenfarbe des " ist hellblau}
button_colors[1,11,1]:=14; {Rahmenfarbe des " ist gelb}
randomize;
for t:=1 to pieces do begin {Zufallsfarben für die Buttons v. Ebene 2}
button_colors [2,t,0]:=random(16); {Hintergrundfarbe}
button_colors [2,t,1]:=random(16); {Umrandungsfarbe}
repeat
button_colors [2,t,2]:=random(16); {Textfarbe}
until button_colors[2,t,2]<>button_colors[2,t,0];
end;
end;
procedure clearmouse;
var a,b,c : integer;
begin
repeat mousestat(a,b,c) until c=0 ; {alle Mausknöpfe loslassen}
end;
procedure call_plane_1;
var t,button,mb,hz : integer;
snd : boolean;
mychar : char;
begin
hz:=30 ; snd:=false ; mychar:=chr(255);
clearmouse;
mouseoff;
if vga_ega_card then begin
setfillstyle(1,7);
bar(0,0,getmaxx,getmaxy) {Bildschirm füllen}
end
else cleardevice; {oder löschen}
mouseon;
defbuttonplane(1); {1. Ebene anzeigen lassen}
line (2*getmaxx div 3,0,2*getmaxx div 3,getmaxy div 3);
line (2*getmaxx div 3,getmaxy div 3,2*getmaxx,getmaxy div 3);
repeat
if keypressed then mychar:=readkey; {Tastatur lesen}
if ord(mychar)=0 then begin {Test auf erw. Tast.-Code}
if keypressed then mychar:=readkey {Erw. Code holen}
else mychar:=chr(255); {oder mychar auf 255}
end
else mychar:=chr(255); {255 heißt : keine Aktion}
pressedbutton(button,mb,mychar); {Buttons überprüfen lassen}
if mb<>0 then begin {User hat Mausbutton gedr.}
case button of {bzw. ALT ? gedrückt}
0 : ; {in button steht der gedr.}
1 : begin {Button - es folgt Reaktion}
revertbutton(1) ; clearmouse;
if snd then nosound
else sound(hz); {Soundschalter}
snd:=not snd;
revertbutton(1);
end;
2 : begin
revertbutton(2);
hz:=hz+1;
if hz>10000 then hz:=10000;
if snd then sound(hz); {Frequenz +}
revertbutton(2);
end;
3 : begin
revertbutton(3);
hz:=hz-1;
if hz<15 then hz:=15;
if snd then sound(hz); {Frequenz -}
revertbutton(3);
end;
4 : begin {Mousewindow}
revertbutton(4) ; clearmouse ;
mousewindow (2*getmaxx div 3,0,getmaxx,getmaxy div 3-2) ;
revertbutton(4);
end;
5 : begin
revertbutton(5) ; clearmouse ; {Freie Maus}
mousewindow (0,0,getmaxx,getmaxy);
revertbutton(5);
end;
6 : plane:=2; {Ebenenumschaltung}
7 : begin
revertbutton(7); {Abwarten}
mouseoff ; delay (3000) ; mouseon;
revertbutton(7);
end;
8 : plane:=0 ; {Porgramm verlassen}
9 : begin
revertbutton(9);
mouseset(round(70/80*getmaxx),round(12.2/25*getmaxy));
revertbutton(9);
clearmouse; {1. Teleport}
end;
10 : begin
revertbutton(10);
mouseset(round(9/80*getmaxx),round(12.2/25*getmaxy));
revertbutton(10);
clearmouse; {2. Teleport}
end;
11 : begin
revertbutton(11);
info_window('!','Ein solches Fenster ist mit'
,'einem einzigen Befehl schnell'
,'und einfach zu öffnen!');
revertbutton(11);
clearmouse; {Kurzinfo}
end;
end;
end;
until plane<>1;
if snd then begin
revertbutton(1) ; snd:=false ; nosound;
end;
end;
procedure call_plane_2;
var t,button,mb : integer;
mychar : char;
begin
clearmouse;
mychar:=chr(255); {Zeichen für "nichts los"}
mouseoff ; cleardevice ; mouseon;
defbuttonplane(2);
repeat
for t:=1 to pieces do begin
if keypressed then mychar:=readkey; {Tastatur lesen}
if ord(mychar)=0 then begin {Test auf erw. Tast.-Code}
if keypressed then mychar:=readkey {Erw. Code holen}
else mychar:=chr(255); {oder mychar auf 255}
end
else mychar:=chr(255); {255 heißt : keine Aktion}
pressedbutton(button,mb,mychar); {Buttons überprüfen lassen}
if (mb=1) and (button=pieces+1) then begin
plane:=1 ; exit ; end;
revertbutton(t); delay(20);
end;
until false;
end;
{Hauptprogramm}
begin
enter_default_graphmode; {Standard-Grafikmodus auswählen}
cleardevice; {Bildschirm löschen}
mousetest; {Anwesenheit der Maus ermitteln}
install_buttonplane_1; {Buttons der Ebene 1 definieren}
install_buttonplane_2; {Buttons der Ebene 2 definieren}
if vga_ega_card then install_colors; {Eventuell Farben definieren}
mouseon; {Maus einschalten}
plane:=1; {Start auf Ebene 1}
repeat
case plane of
1 : call_plane_1 ; {Ebene 1 aufrufen}
2 : call_plane_2 ; {Ebene 2 aufrufen}
end;
until plane=0; {Ebene 0 steht für Demo-Ende}
mouseoff; {Maus wieder abschalten}
cleardevice; {Den Grafikbildschirm löschen}
closegraph; {Grafikmodus wieder verlassen}
end. {Programmende}